using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class DocumentProgressMap : EntityTypeConfiguration<DocumentProgress>
    {
        public DocumentProgressMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(200);

            this.Property(t => t.WorkDetails)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.ProgressCode)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("DocumentProgress");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.WorkDetails).HasColumnName("WorkDetails");
            this.Property(t => t.ProgressCode).HasColumnName("ProgressCode");
            this.Property(t => t.DocReceiveId).HasColumnName("DocReceiveId");
            this.Property(t => t.DocPublishId).HasColumnName("DocPublishId");
            this.Property(t => t.IsFinished).HasColumnName("IsFinished");
            this.Property(t => t.CreatedAt).HasColumnName("CreatedAt");
            this.Property(t => t.UpdatedAt).HasColumnName("UpdatedAt");
            this.Property(t => t.IsCancel).HasColumnName("IsCancel");
            this.Property(t => t.CreatorId).HasColumnName("CreatorId");

            // Relationships
            this.HasOptional(t => t.DocumentInbox)
                .WithMany(t => t.DocumentProgresses)
                .HasForeignKey(d => d.DocReceiveId);

        }
    }
}
